$(function () {


    $('body').on("click",'.openReport',function(){
       var id = $(this).data("id");
        if(id=="0"){
            Zepto.toast("你还没有做过该章节得随堂练习");
            return;
        }
        var byCourseId = $(this).data("bycourse");
        var courseId = $(this).data("course");
        var catalogId = $(this).data("catalog");
        var scorePercent = $(this).data("percen");
        var pass = $(this).data("pass");

        window.location.href ="/mobile/uc/course/play/record/userExercisesRecord?examRecordId="+id+"&courseId="+courseId+"&catalogId="+catalogId+"&scorePercent="+scorePercent+"&pass="+pass+"&byCourseId=" +byCourseId
    }).on("click",".learn",function(){
        var byCourseId = $(this).data("bycourse");
        var courseId = $(this).data("course");
        var catalogId = $(this).data("catalog");
        var type = $(this).data("type");
        var url ="/mobile/course/info"
        if(type=="LIVE"){
            url="/mobile/course/liveInfo"
        }
        url+= "?courseId="+byCourseId+"&catalogId="+catalogId;
        if(courseId!=byCourseId){
            url+="&packageCourseId="+courseId;
        }
        window.location.href=baseloaction +url;
    });
    //执行加载数据
    loadUserStudyData(1);

    /**
     * 加载用户学习记录
     * @param pageNo 页码
     */
    function loadUserStudyData(pageNo) {
        var params = {};
        params.buyCourseId=$("input[name='courseId']").val();
        params.courseType=$("input[name='courseType']").val();
        params = JSON.stringify(params);
        loadMobilePathData({
            url: baseloaction + '/mobile/uc/course/play/record/ajaxUserStudyRecord',
            contextId: 'user-study-box-list-box',
            pageNo: pageNo,
            pageCall: loadUserStudyData,
            params: params,
            callback: function (pageNo) {
                lazyloadImage();
            }
        });
    }
});